from django.db import models
from op_drf.base import BaseModel
# Create your models here.

class StarUser(BaseModel):
    username = models.CharField(max_length=50, default="", verbose_name="用户名", help_text="用户名")
    pwd = models.CharField(max_length=100, default="", verbose_name="密码", help_text="密码")
    fullname = models.CharField(max_length=20, default="", verbose_name="姓名", help_text="姓名")
    sex = models.CharField(max_length=10, default="", verbose_name="性别", help_text="性别")
    email = models.CharField(max_length=50,default="",verbose_name="邮箱",help_text="邮箱")
    mobile = models.CharField(max_length=50, default="", verbose_name="电话", help_text="电话")
    address = models.CharField(max_length=50, default="", verbose_name="地址", help_text="地址")
    modfitypwd = models.BooleanField(null=False, default=False, verbose_name="登录后是否需要修改密码的标记")

    class Meta:
        db_table = "xyx_staruser"
        verbose_name = "向阳星用户"
        verbose_name_plural = verbose_name

class LoginHistory(models.Model):
    user = models.ForeignKey(to=StarUser,on_delete=models.SET_NULL,null=True,verbose_name="用户",help_text="用户")
    username = models.CharField(max_length=50, default="", verbose_name="登录用户序号", help_text="登录用户序号")
    pwd = models.CharField(max_length=100, default="", verbose_name="登录密码", help_text="登录密码")

    loginip = models.CharField(max_length=30,verbose_name="登录ip",help_text="登录ip", null = False, blank = True, default = "")
    loginos = models.CharField(max_length=30,verbose_name="登录系统",help_text="登录系统",null=True)
    loginaddress = models.CharField(max_length=100,verbose_name="登录地点",help_text="登录地点",null=True)
    logintime = models.DateTimeField(verbose_name="登录时间",help_text="登录时间")
    loginstatus = models.BooleanField(verbose_name="登录状态",help_text="登录状态",null=False,default=False)
    loginnum = models.CharField(max_length=80,verbose_name="登录编号",help_text="登录编号",null=True)


    class Meta:
        db_table = "xyx_loginhistory"
        verbose_name = "登录记录"
        verbose_name_plural = verbose_name